package com.deer.wms.base.system.web;

import com.alibaba.fastjson.JSONArray;
import com.deer.wms.base.system.model.task.TaskInfo;
import com.deer.wms.base.system.util.JedisServiceUtil;
import com.deer.wms.base.system.util.RedisUtil;
import com.deer.wms.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 李帅辰
 * @date 2021/1/20 16:08
 */
@Controller
@RequestMapping("/redisDemo")
public class RedisDemoController  extends BaseController {
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private JedisServiceUtil jedisServiceUtil;
    /**
     * 添加 
     * @author 李帅辰
     * @date 2021/1/20 16:57 
     * @return void
     */
    @GetMapping("/insert")
    @ResponseBody
    public void insert(){
        String key="billIn-task";
        String value="";
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setCellCode("12324");
        //taskInfo.setRoadWay(1);
        for (int i=0;i<=5;i++){
            redisUtil.leftPush(key,taskInfo);
        }
    }
/*
    *//**
     *删除
     * @author 李帅辰
     * @date 2021/1/20 16:57 
     * @return void
     *//*
    @PostMapping("/del")
    @ResponseBody
    public void del(String val){
        jedisServiceUtil.DelList(val);
    }*/

    
    /**
     *获取
     * @author 李帅辰
     * @date 2021/1/20 17:00
     * @return java.lang.Object
     */
    @PostMapping("/getLast")
    @ResponseBody
    public Object getLast(String key,Long index){
        return  redisUtil.lGetIndex(key, index);

    }
}
